#ifndef GUIWP_WIDGET__
#define GUIWP_WIDGET__

#include "widget_base.hpp"

#include <string>

#define CHECK_FUN(Policy, Member) enum { Policy##Member = sizeof(&Policy::Member) > 0 };
namespace GUIWP{
template 
  <
  class ContentPolicy,
  class SizePolicy,
  class ClickPolicy,
    template <class T> class DrawingPolicy
  >
class widget : 
  public widget_base,
  public ContentPolicy,
  public ClickPolicy,
  public DrawingPolicy<SizePolicy>
{
int i;
  typedef widget<ContentPolicy,SizePolicy, ClickPolicy,DrawingPolicy> type;
//    CHECK_FUN(DrawingPolicy<SizePolicy>, draw)
  
  public:

    widget(widget_base* parent, const std::string& text = "",unsigned int width = 800, unsigned int height = 600)
      : widget_base(parent), ContentPolicy(text), DrawingPolicy<SizePolicy>(width, height)
  {
  }

    virtual ~widget()
    {
        //si l'objet actuel n'est pas dans la liste des objets alloué dynamiquement
	if(std::find(allDyn.begin(),allDyn.end(),this)==allDyn.end()) 
	{
	    if(parent != NULL)
	    {
		parent->remove_child(this);
		parent->register_child(new type(*this));
	    }
	}
    }

    void draw(Moteur_Base& b)
    {
	DrawingPolicy<SizePolicy>::draw(b);	
	//b.draw(content());
    }
};
}
#endif // GUIWP_WIDGET__
